package com.video_study.controller;

import com.video_study.pojo.Users;
import com.video_study.result.ResponseData;
import com.video_study.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping(value = "/code" ,method = RequestMethod.GET)
    public void code(HttpServletRequest request, HttpServletResponse response){
        loginService.getCode(request,response);
    }

    @RequestMapping("/")
    public String index(){
        return "index";
    }

    @RequestMapping(value = "/userlogin" ,method = RequestMethod.GET)
    @ResponseBody
    public ResponseData code(HttpServletRequest request, String username, String password, String code){
        return  loginService.login(request,username,password,code);
    }

}
